#define  _CRT_SECURE_NO_WARNINGS
#include<stdbool.h>
#include<stdio.h>
char pop(char a)
{
    if (a == '}')
        return '{';
    if (a == ']')
        return '[';
    if (a == ')')
        return '(';
    return 0;
}

bool isValid(char* s)
{
    int sz = strlen(s);
    if (sz % 2 != 0)
        return false;
    char arr[5000]; /*char arr[sz + 1]*/  int top = 0;
    for (int i = 0; i < sz; i++)
    {
        char ch = pop(s[i]);
        if (ch)
        {
            if (top == 0 || arr[top - 1] != ch)
                return false;

            top--;
        }

        else
            arr[top++] = s[i];
    }
    return top == 0;
}
int main()
{
    char* s = "([]){}";
    printf("%d", isValid(s));


    return 0;
}